﻿package mortal.game.view.guildNew.data
{
    import com.mui.controls.*;
    import flash.display.*;
    import flash.utils.*;
    import mortal.common.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.mainUI.Navbar.*;
    import mortal.mvc.core.*;

    public class AutoGuideRedPoint3 extends Object
    {
        private var _map:Dictionary;
        private var _otherFriuts:GImageBitmap;
        public static const GuildSkillLvUp:String = "GuildSkillLvUp";
        public static const GuildGarden:String = "GuildGarden";
        public static var isSkillFull:Boolean = false;
        private static var _instance:AutoGuideRedPoint3;

        public function AutoGuideRedPoint3()
        {
            this.initMap();
            this.addEvents();
            return;
        }// end function

        private function initMap() : void
        {
            return;
        }// end function

        private function addEvents() : void
        {
            EventUtil.addSelfEvent(EventName.NavbarButtonUIRowInited, this.initHd, true);
            Dispatcher.addEventListener(EventName.NavBarButtonPosUpdate, this.onNavBarButtonPosUpdate);
            NetDispatcher.addCmdListener(ServerCommand.GuildResourceAdd, this.onGuildResourceAdd);
            return;
        }// end function

        private function initHd(param1:Object) : void
        {
            this.onNavBarRegister();
            this.onGuildResourceAdd();
            return;
        }// end function

        private function onNavBarRegister() : void
        {
            var _loc_1:* = GameController.navbar.view as NavbarModule;
            var _loc_2:* = _loc_1.btnBottomContainer.getChildByName(ModuleType.Guild) as GLoadedButton;
            ShineBtnManager.instance.register(GuildSkillLvUp, _loc_2);
            return;
        }// end function

        public function unShineMainBtn(param1:String) : void
        {
            var _loc_2:* = GameController.navbar.view as NavbarModule;
            var _loc_3:* = _loc_2.btnBottomContainer.getChildByName(param1) as GLoadedButton;
            if (_loc_3)
            {
                ShineBtnManager.instance.unShineNotRemove(_loc_3);
            }
            return;
        }// end function

        private function onNavBarButtonPosUpdate(event:DataEvent) : void
        {
            this.onNavBarRegister();
            return;
        }// end function

        public function register(param1:String, param2:DisplayObject) : void
        {
            if (this.canSkillUpdate())
            {
                ShineBtnManager.instance.register(param1, param2);
            }
            return;
        }// end function

        public function canSkillUpdate() : Boolean
        {
            return GuildNewUtil.getSkillLeft() > 0;
        }// end function

        public function unRegister(param1:String, param2:DisplayObject) : void
        {
            ShineBtnManager.instance.unRegister(param1, param2);
            return;
        }// end function

        private function onGuildResourceAdd(param1:Object = null) : void
        {
            var _loc_2:* = GuildNewUtil.hasSkillToUpgrate();
            if (_loc_2 && this.canSkillUpdate())
            {
                ShineBtnManager.instance.shineBtn(GuildSkillLvUp, true);
            }
            else if (_loc_2 == false || this.canSkillUpdate == false)
            {
                ShineBtnManager.instance.shineBtn(GuildSkillLvUp, false);
            }
            Dispatcher.dispatchEvent(new DataEvent(GuildNewLocalEvent.GuildNewSkillResourceAdd));
            return;
        }// end function

        public function onNavBarAddFruite(param1:Boolean) : void
        {
            var _loc_2:* = GameController.navbar.view as NavbarModule;
            var _loc_3:* = _loc_2.btnBottomContainer.getChildByName(ModuleType.Guild) as GLoadedButton;
            if (param1 == false && this._otherFriuts)
            {
                this._otherFriuts.visible = param1;
                return;
            }
            if (param1)
            {
                if (this._otherFriuts == null)
                {
                    this._otherFriuts = UIFactory.gImageBitmap(ImagesConst.guidlRankFruite3, 13, 0, null);
                }
                this._otherFriuts.visible = param1;
                if (_loc_3)
                {
                    _loc_3.addChild(this._otherFriuts);
                }
            }
            return;
        }// end function

        public static function get instance() : AutoGuideRedPoint3
        {
            if (_instance == null)
            {
                _instance = new AutoGuideRedPoint3;
            }
            return _instance;
        }// end function

    }
}
